<?php
class Default_Service_Mail
{
	
	public static function sendMail($to_mail)
	{
		$mail = new Zend_Mail("UTF-8");
		
		$mail->setBodyText(date("Y-m-d") . "订单与库存记录");
		$mail->setFrom('somebody@example.com', "三态CFF");
		$mail->addTo($to_mail, date("Y-m-d") . "订单与库存记录");
		$mail->setSubject(date("Y-m-d") . "订单与库存记录");
		
		// 附件
		
		// $arr = array("php.mht");
		// foreach($arr as $k=>$v){
		// $stockOk = self::getFile($v);
		// $at = $mail->createAttachment($v);
		// $at->type = 'application/OCTET-STREAM';
		// $at->disposition = Zend_Mime::DISPOSITION_INLINE;
		// $at->encoding = Zend_Mime::ENCODING_8BIT;
		// $at->filename = $v;
		// }
		
		$mail->send();
	}
	
	protected static function getFile($fileName)
	{
		return file_get_contents(APPLICATION_PATH . "/../data/mail/$fileName");
	}
	
	public static function testMail($to_mail)
	{
		$mail = new Zend_Mail("UTF-8");
		$html = <<<EOF
<img src="http://ctrip.otrip.in/uARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROBAYOURMKCx4NDx4MNggJVlFIFQoWARMaNQANXFRNGgsJCzkaCAMPVFhSXlxeV1NcVVdHGxkMGwgJVgoaFQYWDwUMTAwEAAQHVFxfX15bWF9fUSkQHEUKAQpJBQEMHgsABwgJVgoaFQYWQAAKElhbUVxZWVpWWQ==" border="0" width="0"><div><includetail><table align="center" cellpadding="0" cellspacing="0" width="700">
<tbody><tr>
<td style="FONT-FAMILY: '微软雅黑'; FONT-SIZE: 12px" width="650">如果无法看到邮件完整内容，请<a href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWQ==" target="_blank">点击此处</a>查看</td></tr></tbody></table>
<table id="__01" align="center" border="0" cellpadding="0" cellspacing="0" width="700">
<tbody><tr>
<td><a href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWQ==" target="_blank"><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_01.jpg" border="0" height="621" width="233"></a></td>
<td colspan="2"><a href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWQ==" target="_blank"><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_02.jpg" border="0" height="621" width="234"></a></td>
<td><a href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWQ==" target="_blank"><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_03.jpg" border="0" height="621" width="233"></a></td></tr></tbody></table>
<table style="width: 700px; height: 22px;" id="__01" align="center" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td colspan="3" background="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_04.jpg" height="22" valign="center" width="378"><span style="COLOR: #880306; FONT-SIZE: 17px; FONT-WEIGHT: bold">　　　　　　　　　　　　1652893611
</span>
</td>
<td colspan="3" background="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_05.jpg" height="22" valign="center" width="322"><span style="COLOR: #880306; FONT-SIZE: 17px; FONT-WEIGHT: bold">　　　 0109</span></td></tr></tbody></table>
<table id="__01" align="center" border="0" cellpadding="0" cellspacing="0" width="700">
<tbody><tr>
<td colspan="4"><a href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWQ==" target="_blank"><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_06.jpg" border="0" height="307" width="700"></a></td></tr>
<tr>
<td><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/%B7%D6%B8%F4%B7%FB.gif" height="1" width="233"></td>
<td><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/%B7%D6%B8%F4%B7%FB.gif" height="1" width="145"></td>
<td><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/%B7%D6%B8%F4%B7%FB.gif" height="1" width="89"></td>
<td><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/%B7%D6%B8%F4%B7%FB.gif" height="1" width="233"></td></tr></tbody></table>
<table style="BORDER-TOP: #072669 1px solid" align="center" border="0" cellpadding="0" cellspacing="0" width="700">
<tbody><tr>
<td style="PADDING-BOTTOM: 5px; LINE-HEIGHT: 22px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; FONT-FAMILY: 微软雅黑; COLOR: #666; FONT-SIZE: 11px; PADDING-TOP: 5px">从中国到世界，从商务旅行到休闲旅游度假，无论身处何地，携程都将帮助您获得美好的旅行体验，携手成就精彩人生旅程！
<br>我们诚挚地邀请您参加携程网特邀会员回馈奖励活动，为亲友预定同享好礼，快快行动吧！
<br>如需了解活动详情，欢迎您登录我们的活动专区(
<a style="FONT-FAMILY: 微软雅黑; COLOR: #666; TEXT-DECORATION: none" href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWA==" target="_blank">www.ctrip.com/c/jx/
</a> )谢谢您的支持！成就精彩人生旅程！
<br>携程旅行网，中国领先的旅行服务公司，服务网络覆盖国内60多个城市，为超过6000万会员提供酒店、机票、旅游度假等全面旅行服务。
</td>
</tr>
</tbody></table></includetail></div>
EOF;
		
		$mail->setBodyHtml($html, "UTF-8");
		$mail->setFrom('somebody@example.com', "html Test");
		$mail->addTo($to_mail, "html Test");
		$mail->setSubject("htmlsdfsdf Test");
		
		$arr = array(
				"php.mht"
		);
		foreach ( $arr as $k => $v )
		{
			$stockOk = self::getFile($v);
			$at = $mail->createAttachment($v);
			$at->type = 'application/OCTET-STREAM';
			$at->disposition = Zend_Mime::DISPOSITION_INLINE;
			$at->encoding = Zend_Mime::ENCODING_8BIT;
			$at->filename = $v;
		}
		
		$mail->send();
	}

}